<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>ECharts</title>
    <style type="text/css">
        body{
            background-color:#DCDCDC;
        }
        #zzbq{
            text-align: center;
            margin:0 auto;
            margin-top: 3%;
            width:800px; height:10px;

        }
        #zzbq a{ text-decoration:none }
        #github{
            margin:0 auto;
            padding-left: 3%;
            width:800px; height:0px;
        }
        #github a{ font-weight: bold;text-decoration:none; }
        #main{
            margin: auto;
            margin-top: 3%;
            width:800px; height:600px;
            border: 0px solid red;
        }
    </style>

    <!-- 1.引入 echarts.js -->
    <script src="../echarts3_line/echarts4.2.js"></script>
</head>
<body>

    <div id='zzbq'>
        <span style='font-weight: bold;'>其他图：</span>
        <a href="../echarts3_line/index.html">柱+折线图</a>
        <a href="../echarts3_pie/index.html">饼图</a>
        <a href="../echarts3_map_China/index.html">迁徙图</a>
        <a href="../echarts3_map_baiduApi/index.html">接入百度地图</a>
        
    </div>

    <div id='github'>
        <a href="https://github.com/zpj80231/EChartsStudy">github源码</a>
    </div>

    <!-- 2.为ECharts准备一个具备大小（宽高）的Dom -->
    <div id="main"></div>
    
    <script type="text/javascript">
        // 3.基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));
        
        // 4.   
        var data = genData(50);

option = {
    title : {
        text: '同名数量统计',
        subtext: '纯属虚构',
        x:'center'
    },
    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    toolbox: {
        show : true,
        feature : {
            mark : {show: true},
            dataView : {show: true, readOnly: false},
            magicType : {
                show: true,
                type: ['pie', 'funnel']
            },
            restore : {show: true},
            saveAsImage : {show: true}
        }
    },
    legend: {
        type: 'scroll',
        orient: 'vertical',//显示为垂直
        right: 10,
        top: 32,
        bottom: 20,
        data: data.legendData,

        selected: data.selected
    },
    series : [
        {
            name: '姓名',
            type: 'pie',
            roseType : 'radius',//加上则是南丁格尔玫瑰图
            radius : '55%',
            center: ['40%', '50%'],
            data: data.seriesData,
            itemStyle: {
                emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ],
    
};




function genData(count) {
    var nameList = [
        '赵', '钱', '孙', '李', '周', '吴', '郑', '王', '冯', '陈', '褚', '卫', '蒋', '沈', '韩', '杨', '朱', '秦', '尤', '许', '何', '吕', '施', '张', '孔', '曹', '严', '华', '金', '魏', '陶', '姜', '戚', '谢', '邹', '喻', '柏', '水', '窦', '章', '云', '苏', '潘', '葛', '奚', '范', '彭', '郎', '鲁', '韦', '昌', '马', '苗', '凤', '花', '方', '俞', '任', '袁', '柳', '酆', '鲍', '史', '唐', '费', '廉', '岑', '薛', '雷', '贺', '倪', '汤', '滕', '殷', '罗', '毕', '郝', '邬', '安', '常', '乐', '于', '时', '傅', '皮', '卞', '齐', '康', '伍', '余', '元', '卜', '顾', '孟', '平', '黄', '和', '穆', '萧', '尹', '姚', '邵', '湛', '汪', '祁', '毛', '禹', '狄', '米', '贝', '明', '臧', '计', '伏', '成', '戴', '谈', '宋', '茅', '庞', '熊', '纪', '舒', '屈', '项', '祝', '董', '梁', '杜', '阮', '蓝', '闵', '席', '季', '麻', '强', '贾', '路', '娄', '危'
    ];
    var legendData = [];
    var seriesData = [];
    var selected = {};
    for (var i = 0; i < 50; i++) {
        name = Math.random() > 0.65
            ? makeWord(4, 1) + '·' + makeWord(3, 0)
            : makeWord(2, 1);
        legendData.push(name);
        seriesData.push({
            name: name,
            value: Math.round(Math.random() * 100000)
        });
        selected[name] = i < 6;
    }

    return {
        legendData: legendData,
        seriesData: seriesData,
        selected: selected
    };

    function makeWord(max, min) {
        var nameLen = Math.ceil(Math.random() * max + min);
        var name = [];
        for (var i = 0; i < nameLen; i++) {
            name.push(nameList[Math.round(Math.random() * nameList.length - 1)]);
        }
        return name.join('');
    }
}



        
        // 5.使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
		</script>
    
</body>
</html>